class MyQueue {
private:
    stack<int> front;   // 队头
    stack<int> back;    // 队尾
public:
    MyQueue() { }

    void push(int x) {
        back.push(x);
    }
    
    int pop() {
        int ret = peek();
        front.pop();
        return ret;
    }
    
    int peek() {
        if(front.empty()){
            if(back.empty()) return 0;
            // 将back元素移到front中
            while(!back.empty()){
                front.push(back.top());
                back.pop();
            }
        }

        return front.top();
    }
    
    bool empty() {
        return back.empty() && front.empty();
    }
};

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue* obj = new MyQueue();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->peek();
 * bool param_4 = obj->empty();
 */